package com.hedl.practice.diyJava.gather.study_priority_queue.utils;

import com.hedl.practice.diyJava.gather.study_priority_queue.tmp.User;

import java.util.Comparator;

public class UserComparator implements Comparator<User> {
    @Override
    public int compare(User o1, User o2) {
        if (o1.number.charAt(0) == o2.number.charAt(0)){
            Integer n1 = Integer.valueOf(o1.number.substring(1));
            Integer n2 = Integer.valueOf(o2.number.substring(1));
            //如果两人的号都是A开头或者都是V开头,比较号的大小:
            return n1.compareTo(n2);
        }
        if (o1.number.charAt(0) == 'V'){
            //u1的号码是V开头,优先级高:
            return -1;
        }else {
            return 1;
        }
    }
}
